package com.ruoyi.student.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.student.domain.vo.TCourseInfoVo;
import com.ruoyi.student.domain.vo.TStudentVo;
import com.ruoyi.student.mapper.ReCourseClassMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.student.mapper.TStudentMapper;
import com.ruoyi.student.domain.TStudent;
import com.ruoyi.student.service.ITStudentService;

/**
 * 学生Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-15
 */
@Service
public class TStudentServiceImpl implements ITStudentService 
{
    @Autowired
    private TStudentMapper tStudentMapper;

    @Autowired
    private ReCourseClassMapper reCourseClassMapper;

    /**
     * 查询学生
     * 
     * @param id 学生主键
     * @return 学生
     */
    @Override
    public TStudent selectTStudentById(Long id)
    {
        return tStudentMapper.selectTStudentById(id);
    }

    /**
     * 查询学生列表
     * 
     * @param tStudent 学生
     * @return 学生
     */
    @Override
    public List<TStudent> selectTStudentList(TStudent tStudent)
    {
        return tStudentMapper.selectTStudentList(tStudent);
    }
    @Override
    public List<TStudentVo> selectTStudentVoList(TStudent tStudent)
    {
        return tStudentMapper.selectTStudentVoList(tStudent);
    }
    @Override
    public TStudentVo selectTStudentVoById(Long id)
    {
        TStudentVo tStudentVo = tStudentMapper.selectTStudentVoById(id);
        List<TCourseInfoVo> tCourseInfoVos = reCourseClassMapper.selectCourseListByClassId(tStudentVo.getClassId());
        tStudentVo.setTCourseInfoVos(tCourseInfoVos);
        return tStudentVo;
    }

    /**
     * 根据班级id查询所有的课程
     *
     * @param id 课程班级关联主键
     * @return 课程列表
     */
    public List<TCourseInfoVo> selectCourseListByClassId(Long id){
        return reCourseClassMapper.selectCourseListByClassId(id);
    }

    /**
     * 新增学生
     * 
     * @param tStudent 学生
     * @return 结果
     */
    @Override
    public int insertTStudent(TStudent tStudent)
    {
        tStudent.setCreateTime(DateUtils.getNowDate());
        return tStudentMapper.insertTStudent(tStudent);
    }

    /**
     * 修改学生
     * 
     * @param tStudent 学生
     * @return 结果
     */
    @Override
    public int updateTStudent(TStudent tStudent)
    {
        tStudent.setUpdateTime(DateUtils.getNowDate());
        return tStudentMapper.updateTStudent(tStudent);
    }

    /**
     * 批量删除学生
     * 
     * @param ids 需要删除的学生主键
     * @return 结果
     */
    @Override
    public int deleteTStudentByIds(Long[] ids)
    {
        return tStudentMapper.deleteTStudentByIds(ids);
    }

    /**
     * 删除学生信息
     * 
     * @param id 学生主键
     * @return 结果
     */
    @Override
    public int deleteTStudentById(Long id)
    {
        return tStudentMapper.deleteTStudentById(id);
    }
}
